* Clean up
clear all

/* Set working directory: please set your own
cd "~/Dropbox/JOP third submission/JOP replication/"
*/

* Open dataset

use 01_data/whole_spain.dta, clear

* Fake model to get the dataset started
reg ep post 
regsave post using 01_data/jackknives_ddd.dta, ci replace addlabel (Region, 0, Model, 0)


forvalues x = 1/3 {
reghdfe pp_voteshare post##ep##ciutadella if period > 1 & CODCCAA != `x', absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
regsave 1.post#1.ep#1.ciutadella using 01_data/jackknives_ddd.dta, ci append addlabel (Region, `x', Model, Model 1)
	
reghdfe pp_voteshare post##ep##ciutadella if CODCCAA != `x', absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
regsave 1.post#1.ep#1.ciutadella using 01_data/jackknives_ddd.dta, ci append addlabel (Region, `x', Model, Model 2)


reghdfe pp_voteshare post##ep##ciutadella i.period if CODCCAA != `x', absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
regsave 1.post#1.ep#1.ciutadella using 01_data/jackknives_ddd.dta, ci append addlabel (Region, `x', Model, Model 3)
}

* CCAA code 4 is Balearic Islands, which is why I don't remove it

forvalues x = 5/19 {
reghdfe pp_voteshare post##ep##ciutadella if period > 1 & CODCCAA != `x', absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
regsave 1.post#1.ep#1.ciutadella using 01_data/jackknives_ddd.dta, ci append addlabel (Region, `x', Model, Model 1)
	
reghdfe pp_voteshare post##ep##ciutadella if CODCCAA != `x', absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
regsave 1.post#1.ep#1.ciutadella using 01_data/jackknives_ddd.dta, ci append addlabel (Region, `x', Model, Model 2)

reghdfe pp_voteshare post##ep##ciutadella i.period if CODCCAA != `x', absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
regsave 1.post#1.ep#1.ciutadella using 01_data/jackknives_ddd.dta, ci append addlabel (Region, `x', Model, Model 3)
}
